

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>登入 - EP教育管理后台</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="static/layuiadmin/style/admin.css" media="all">
  <link rel="stylesheet" href="static/layuiadmin/style/login.css" media="all">
  <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
</head>
<body>

  <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">

    <div class="layadmin-user-login-main">
      <div class="layadmin-user-login-box layadmin-user-login-header">
        <h2>某知名教育平台管理系统</h2>
        <p>Java Python Web前端开发 UI设计</p>
      </div>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
          <input type="text" name="loginName" id="LAY-user-login-username" lay-verify="required" placeholder="登录名"  class="layui-input">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
          <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码"  class="layui-input">
        </div>
        <div class="layui-form-item" style="margin-bottom: 20px;">
          <input type="checkbox" name="remember" lay-skin="primary" title="7天免登录">
          <a onclick="forget()" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit" onclick="login()">登 入</button>
        </div>
      </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">

      <p>© 2010-2020 <a href="http://www.layui.com/" target="_blank">five.test</a></p>
      <p>
        <span><a href="#" target="_blank">十年品牌</a></span>
        <span><a href="#" target="_blank">值得信赖</a></span>
        <span><a href="#" target="_blank">关于我们</a></span>
      </p>
    </div>


  </div>

  <script src="static/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: 'static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'user'], function(){
    var $ = layui.$
    ,setter = layui.setter
    ,admin = layui.admin
    ,form = layui.form
    ,router = layui.router()
    ,search = router.search;

    form.render();

    //提交
    // form.on('submit(LAY-user-login-submit)', function(obj){
    //
    //   let valicode = new TencentCaptcha('2099213336', function(res){
    //     if (res.ret === 0){
    //       //请求登入接口
    //       admin.req({
    //         type:"POST",
    //         url: 'system/login' //实际使用请改成服务端真实接口
    //         ,data: obj.field
    //         ,done: function(res){
    //           if(res.code===0&&res.message !== 'null'){
    //             alert(res.message);
    //             return;
    //           }
    //
    //           // 请求成功后，写入 access_token
    //           // layui.data(setter.tableName, {
    //           //   key: setter.request.tokenName
    //           //   ,value: res.data.access_token
    //           // });
    //
    //           //登入成功的提示与跳转
    //           layer.msg('登入成功', {
    //             offset: '15px'
    //             ,icon: 1
    //             ,time: 1000
    //           }, function(){
    //             console.info(obj.field);
    //             location.href = '/ep/index'; //后台主页
    //           });
    //         }
    //       });
    //     }
    //   });
    //   valicode.show();
    // });
  });
  </script>

  <script src="static/js/jquery.min.js"></script>
  <script>
    function login() {
      let valicode = new TencentCaptcha('2099213336', function(res){
        if (res.ret === 0){
          let loginName = $('#LAY-user-login-username').val();
          let password = $('#LAY-user-login-password').val();
          let remember = $("input[name='remember']:checked").val();
          $.ajax({
            url:"system/login" , // 请求路径
            type:"POST" , //请求方式
            //data: "username=jack&age=23",//请求参数
            data:{
              loginName:loginName,
              password:password,
              remember:remember

            },
            success:function (data) {
              if(data.code!==200){
                alert(data.message)
              }else{
                //此处写 location.href = 'index' 则成功跳转 http://localhost:8080/ep/index
                //此处写 location.href = '/index' 则跳转 http://localhost:8080/index  404报错
                location.href = 'index'; //后台主页
              }
            },error:function () {
              alert("出错啦...")
            }
          });
        }
      });
      valicode.show();
    }
    function forget() {
      alert("请联系管理员重置密码")
    }
  </script>


</body>
</html>
